{include file="common/head"/}
<div class="layui-fluid"><div class="layui-card">

<div class="layui-card-body">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>添加</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" method="post" action="" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline" style="width:400px;">
                <input type="text" name="Title" class="layui-input">
            </div>
        </div>

   <!--<div class="layui-form-item">
            <label class="layui-form-label">简介</label>
            <div class="layui-input-inline" style="width:400px;">
                <input type="text" name="Conten" class="layui-input">
            </div>
        </div>-->

 <style>
  .layui-upload-img{width: 92px; height: 92px; margin: 0 10px 10px 0;}
  </style>

 


        <!--<div class="layui-form-item">
            <label class="layui-form-label">发布时间</label>
            <div class="layui-input-inline" style="width:400px;">
                <input type="text" name="DateTime" class="layui-input" id="date1" placeholder="yyyy-MM-dd HH:mm:ss">
            </div>
        </div>-->
        <!--<div class="layui-form-item">
            <label class="layui-form-label">发布人</label>
            <div class="layui-input-inline" style="width:400px;">
                <input type="text" name="pub_person" class="layui-input">
            </div>
        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label" style="height: 415px;">添加公告</label>
            <div class="layui-inline">
                <div class="layui-input-inline">
                <script id="editor" type="text/plain" style="width:1024px;height:300px;" name="Conten"></script>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-inline" style="width:400px;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
<!--                <a href="{:url('index',['cid'=>input('param.cid')])}" class="layui-btn layui-btn-primary">{:lang('back')}</a>-->
            </div>
        </div>

    </form>
</div>
{include file="common/foot"/}

<script charset="utf-8" src="/public/static/ueditor/ueditor.config.js"></script>
<script charset="utf-8" src="/public/static/ueditor/ueditor.all.min.js"></script>

<script>
var ue = UE.getEditor('editor');

layui.use(['form','laydate','upload'], function() {
    var form  = layui.form,
        $     = layui.$,
        laydate = layui.laydate,
        layer = layui.layer,
        upload = layui.upload;



                  //普通图片上传
 var uploadInst = upload.render({
      elem: '#test-upload-normal'
      ,url: '{:url("UpFiles/upload")}'
      ,before: function(obj){
        //预读本地文件示例，不支持ie8
        obj.preview(function(index, file, result){
          $('#test-upload-normal-img').attr('src', result); //图片链接（base64）
        });
      }
      ,done: function(res){
        if(res.code ==1){
            $('input[name=thumb]').val(res.url)
          return layer.msg('上传成功');
        }
      }

      ,error: function(){
        //演示失败状态，并实现重传
        var demoText = $('#test-upload-demoText');
        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
        demoText.find('.demo-reload').on('click', function(){
          uploadInst.upload();
        });
      }
    });





    //年选择器
    laydate.render({
            elem: '#date1'
		  ,type: 'datetime'
		  ,range: true //或 range: '~' 来自定义分割字符
    });

    //监听提交
    form.on('submit(submit)', function(data) {
        var loading = layer.load(1, { shade: [0.1, '#fff'] });
        $.post("{:url('add')}", data.field, function(res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, { time: 1800, icon: 1 }, function() {
                    location.href = res.url;
                });
            } else {
                layer.msg(res.msg, { time: 1800, icon: 2 });
            }
        });
    });



});
</script>
</body>
</html>